﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSqlError>//数据库错误相关
#include <QSqlDatabase>//连接数据库相关
#include <QSqlQuery>//执行sql语句相关

#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QStandardItemModel>//实现通用的二维数据的管理功能。
#include <QSqlTableModel>
#include <QSqlRecord>

#include <QMessageBox>
#include <QFileDialog>
#include <QString>
#include <QTextStream>
#include <QTextCodec>
#include "qcustomplot.h"
#include <QTime>
#include <QVector>
#include <QTimer>
#include <QTableView>

#include <QAxObject>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QDebug>//程序输出，相当于print
#include <QSortFilterProxyModel>
#include <QHeaderView>
#include "login.h"
#include "ui_login.h"

#include <QRegExp>
#include <QToolTip>
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

signals:
    void valueChanged(bool logined);

public:
    explicit MainWindow(QWidget *parent = 0);
    QString setTableName = NULL;
    ~MainWindow();

//重写closeEvent方法，实现关闭mainwindow的同时关闭非子类的showWidget
protected:
    void closeEvent(QCloseEvent *event) override {
        if(showWidget){
            showWidget->close();
        }
        if(paraWidget){
            paraWidget->close();
        }
        QMainWindow::closeEvent(event);
    }

private slots:

    void on_pushButton_import_clicked();

    void on_pushButton_export_clicked();

    void on_pushButton_delete_clicked();

    void on_pushButton_query_clicked();

    void on_toolButton_search_clicked();

    void on_pushButton_modify_clicked();

    bool distinguishNodes(QString filtername);
    void fatherNodeClicked(QTreeWidgetItem* item ,QString filtername);
    void childrenNodeClicked(QTreeWidgetItem* item,QString filtername);
    void treeWidgetClicked(QTreeWidgetItem *item);//全选全不选
    void Init();

    void creatNewTable(QAxObject *work_sheet);
    void InsertData(QAxObject *work_sheet);
    bool isTableExists(QString &table);
    //void dealInvalidCsvItem(QString filePath);
    void draw(QString lineName,QVector<double> x,QVector<double> y,int lineNumber);
    void selectedShow();
    void contextMenuRequest(QPoint pos);
    void showGraph();
    void hideGraph();
    void on_verticalScrollBar_valueChanged(int value);

    void on_horizontalScrollBar_valueChanged(int value);

    void on_pushButton_removecurves_clicked();

    void on_pushButton_admin_clicked();

    void on_pushButton_home_clicked();

    void updateParentItem(QTreeWidgetItem *item);

    void on_pushButton_testvalue_clicked();

    void on_toolButton_clicked();

    void on_parameterBtn_clicked();

    void on_pushButton_10_clicked();

    void showPointToolTip(QMouseEvent *event);


private:
    Ui::MainWindow *ui;
    QSqlDatabase dbMYSQL;
//    int currentcolumn=0;
    QStandardItemModel *model;
    QSqlTableModel *mymodel;
    int tablecount=0,lineNumber=0;
    QWidget *showWidget;
    QPushButton *parameterBtn;
    QList<QStandardItem*> items1;
    QList<QStandardItem*> items2;
    QList<QStandardItem*> pitems1;
    QList<QStandardItem*> pitems2;
    QStandardItemModel *tdmodel;
    QTableView *tableview;
    QStandardItemModel *paramodel;
    QTableView *ptableview;
    QWidget *paraWidget;


};

#endif // MAINWINDOW_H
